﻿using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.BOS.WebApi.FormService;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace DevSamPle
{
    [Description("【表单插件】全事件"), HotUpdate]
    public class AllEvent : AbstractDynamicFormPlugIn
    {
        #region event
        public override void BeforeExportDataNew(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeExportDataNewArgs e)
        {
            PrintEventInfo("BeforeExportDataNew", e);
            base.BeforeExportDataNew(e);
        }
        public override void CreateNewData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BizDataEventArgs e)
        {
            PrintEventInfo("CreateNewData", e);
            base.CreateNewData(e);
        }
        public override void AfterCreateNewData(System.EventArgs e)
        {
            PrintEventInfo("AfterCreateNewData", e);
            base.AfterCreateNewData(e);
        }
        public override void OnChangeConvertRuleEnumList(Kingdee.BOS.Core.List.PlugIn.Args.ChangeConvertRuleEnumListEventArgs e)
        {
            PrintEventInfo("OnChangeConvertRuleEnumList", e);
            base.OnChangeConvertRuleEnumList(e);
        }
        public override void AfterCreateModelData(System.EventArgs e)
        {
            PrintEventInfo("AfterCreateModelData", e);
            base.AfterCreateModelData(e);
            var bObj = this.Model.DataObject;
            DynamicObject biType = bObj["BillTypeId"] as DynamicObject;
            string typeNumber = biType["Number"].ToString();
            if (!typeNumber.Equals("CGDD01_SYS", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            var context = this.Context;
            var userId = context.UserId;
            var result = WebApiServiceCall.ExecuteBillQuery(this.Context, CustCommon.QueryParameter("SEC_User", "FLinkObject.fname", $"fuserid={userId}"));
            string purchaserName = result[0][0].ToString();
            var ent = this.Model.BillBusinessInfo.GetEntity("FPOOrderEntry");
            var o = this.Model.GetEntityDataObject(ent);
            var entity1 = this.Model.GetEntryRowCount("FPOOrderEntry");
            for (int i = 0; i < entity1; i++)
            {
                this.Model.DeleteEntryRow("FPOOrderEntry", i);
            }
            //this.View.Model.CreateNewEntryRow("FPOOrderEntry");
            var date = DateTime.Now.AddMonths(1);
            this.Model.BatchCreateNewEntryRow("FPOOrderEntry", 6);
            for (int i = 0; i < 6; i++)
            {
                this.Model.SetItemValueByNumber("FMaterialId", "1.01", i);
                this.View.InvokeFieldUpdateService("FMaterialId", i);
                this.Model.SetValue("FQty", i + 1, i);
                this.View.InvokeFieldUpdateService("FQty", i);
                this.Model.SetValue("FTaxPrice", i + 10, i);
                this.View.InvokeFieldUpdateService("FTaxPrice", i);
                this.Model.SetValue("FEntryTaxRate", i + 2, i);
                this.View.InvokeFieldUpdateService("FEntryTaxRate", i);
                this.Model.SetValue("FDeliveryDate", date, i);

            }
            //不能强制 as 转，值会变为null
            var newRows = o.Where(r => Convert.ToInt32(r["Qty"]) == 3) as DynamicObjectCollection;
            var newRows2 = o.Where(r => Convert.ToInt32(r["Qty"]) == 3);
            foreach (var row in newRows2)
            {
                DynamicObject material = row["MaterialId"] as DynamicObject;
                string mNumber = material["Number"].ToString();
                var qty = Convert.ToDecimal(row["Qty"]);
            }
            var nRows = (from p in o
                         where Convert.ToInt32(p["Qty"]) == 3
                         select p);
            //转回DynamicObjectCollection类型方法
            DynamicObjectCollection filterList = new DynamicObjectCollection(o.DynamicCollectionItemPropertyType);

            foreach (var item in newRows2)
            {
                filterList.Add(item);
            }
            //this.Model.DeleteEntryRow()
            //this.Model.ClearNoDataRow();
        }
        public override void BeforeControlDataBinder(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeControlDataBinder e)
        {
            PrintEventInfo("BeforeControlDataBinder", e);
            base.BeforeControlDataBinder(e);
        }
        public override void BeforeEntryRowDataBinder(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeEntryRowDataBinderArgs e)
        {
            PrintEventInfo("BeforeEntryRowDataBinder", e);
            base.BeforeEntryRowDataBinder(e);
        }
        public override void BeforeEntryBatchFill(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeBatchFillEventArgs e)
        {
            PrintEventInfo("BeforeEntryBatchFill", e);
            base.BeforeEntryBatchFill(e);
        }
        public override void AfterEntryBatchFill(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterBatchFillEventArgs e)
        {
            PrintEventInfo("AfterEntryBatchFill", e);
            base.AfterEntryBatchFill(e);
        }
        public override void BeforeCreateNewEntryRow(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeCreateNewEntryEventArgs e)
        {
            PrintEventInfo("BeforeCreateNewEntryRow", e);
            base.BeforeCreateNewEntryRow(e);
        }
        public override void AfterCreateNewEntryRow(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.CreateNewEntryEventArgs e)
        {
            PrintEventInfo("AfterCreateNewEntryRow", e);
            base.AfterCreateNewEntryRow(e);
        }
        public override void BeforeDeleteRow(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeDeleteRowEventArgs e)
        {
            PrintEventInfo("BeforeDeleteRow", e);
            base.BeforeDeleteRow(e);
        }
        public override void AfterDeleteRow(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterDeleteRowEventArgs e)
        {
            PrintEventInfo("AfterDeleteRow", e);
            base.AfterDeleteRow(e);
        }
        public override void BeforeUpdateValue(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeUpdateValueEventArgs e)
        {
            PrintEventInfo("BeforeUpdateValue", e);
            base.BeforeUpdateValue(e);
        }
        public override void DataChanged(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.DataChangedEventArgs e)
        {
            base.DataChanged(e);
            PrintEventInfo("DataChanged", e);
            //var obj = this.Model.DataObject;
            //DynamicObjectCollection row = obj["POOrderEntry"] as DynamicObjectCollection;
            var foreColor = "#ff0000";// 红色
            var grid = this.View.GetControl<EntryGrid>("FPOOrderEntry");
            var a = Convert.ToDecimal(this.Model.GetValue("FQty", e.Row));
            if (e.Field.Key == "FQty")
            {
                this.Model.SetValue("FEntryTaxRate", a, e.Row);
                grid.SetForecolor("FEntryTaxAmount", foreColor, e.Row);
                //设置前景色时，字段必须设置为只读，才生效
                grid.SetForecolor("FEntryTaxRate", foreColor, e.Row);
            }
        }
        public override void AfterCopyRow(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterCopyRowEventArgs e)
        {
            PrintEventInfo("AfterCopyRow", e);
            base.AfterCopyRow(e);
        }
        public override void BeforeDeleteEntry(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeDeleteEntryEventArgs e)
        {
            PrintEventInfo("BeforeDeleteEntry", e);
            base.BeforeDeleteEntry(e);
        }
        public override void AfterDeleteEntry(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterDeleteEntryEventArgs e)
        {
            PrintEventInfo("AfterDeleteEntry", e);
            base.AfterDeleteEntry(e);
        }
        public override System.Collections.Generic.List<Kingdee.BOS.Core.Metadata.TreeNode> GetTreeViewData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.TreeNodeArgs e)
        {
            PrintEventInfo("GetTreeViewData", e);
            return base.GetTreeViewData(e);
        }
        public override void BeforeSetItemValueByNumber(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeSetItemValueByNumberArgs e)
        {
            PrintEventInfo("BeforeSetItemValueByNumber", e);
            base.BeforeSetItemValueByNumber(e);
        }
        public override void GroupSearchMenuPanelAction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.GroupSearchMenuPanelEventArgs e)
        {
            PrintEventInfo("GroupSearchMenuPanelAction", e);
            base.GroupSearchMenuPanelAction(e);
        }
        public override void ProductsPanelAction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ProductsPanelEventArgs e)
        {
            PrintEventInfo("ProductsPanelAction", e);
            base.ProductsPanelAction(e);
        }
        public override void PreOpenForm(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreOpenFormEventArgs e)
        {
            PrintEventInfo("PreOpenForm", e);
            base.PreOpenForm(e);
        }
        public override void OnInitialize(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.InitializeEventArgs e)
        {
            PrintEventInfo("OnInitialize", e);
            base.OnInitialize(e);
        }
        public override void OnInitializeService(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.InitializeServiceEventArgs e)
        {
            PrintEventInfo("OnInitializeService", e);
            base.OnInitializeService(e);
        }
        public override void OnSetBusinessInfo(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.SetBusinessInfoArgs e)
        {
            PrintEventInfo("OnSetBusinessInfo", e);
            base.OnSetBusinessInfo(e);
        }
        public override void OnSetLayoutInfo(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.SetLayoutInfoArgs e)
        {
            PrintEventInfo("OnSetLayoutInfo", e);
            base.OnSetLayoutInfo(e);
        }
        public override void OnCreateDataBinder(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.CreateDataBinderArgs e)
        {
            PrintEventInfo("OnCreateDataBinder", e);
            base.OnCreateDataBinder(e);
        }
        public override void OnLoad(System.EventArgs e)
        {
            PrintEventInfo("OnLoad", e);
            base.OnLoad(e);
        }
        public override void BeforeClosed(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeClosedEventArgs e)
        {
            PrintEventInfo("BeforeClosed", e);
            base.BeforeClosed(e);
        }
        public override void BeforeFlexClosed(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeClosedEventArgs e)
        {
            PrintEventInfo("BeforeFlexClosed", e);
            base.BeforeFlexClosed(e);
        }
        public override void AfterShowFlexForm(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterShowFlexFormEventArgs e)
        {
            PrintEventInfo("AfterShowFlexForm", e);
            base.AfterShowFlexForm(e);
        }
        public override void Dispose()
        {
            PrintEventInfo("Dispose");
            base.Dispose();
        }
        public override void BeforeBindData(System.EventArgs e)
        {
            PrintEventInfo("BeforeBindData", e);
            base.BeforeBindData(e);
        }
        public override void AfterBindData(System.EventArgs e)
        {
            PrintEventInfo("AfterBindData", e);
            base.AfterBindData(e);
            //this.Model.ClearNoDataRow();
            //this.Model.BatchCreateNewEntryRow("FPOOrderEntry", 6);
        }
        public override void AfterUpdateViewState(System.EventArgs e)
        {
            PrintEventInfo("AfterUpdateViewState", e);
            base.AfterUpdateViewState(e);
        }
        public override void OnTimerElapsed(System.EventArgs e)
        {
            PrintEventInfo("OnTimerElapsed", e);
            base.OnTimerElapsed(e);
        }
        public override void OnQueryProgressValue(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.QueryProgressValueEventArgs e)
        {
            PrintEventInfo("OnQueryProgressValue", e);
            base.OnQueryProgressValue(e);
        }
        public override void BarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)
        {
            PrintEventInfo("BarItemClick", e);
            base.BarItemClick(e);
        }
        public override void ContextMenuItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ContextMenuItemClickEventArgs e)
        {
            PrintEventInfo("ContextMenuItemClick", e);
            base.ContextMenuItemClick(e);
        }
        public override void EntryBarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)
        {
            PrintEventInfo("EntryBarItemClick", e);
            base.EntryBarItemClick(e);
        }
        public override void ToolBarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)
        {
            PrintEventInfo("ToolBarItemClick", e);
            base.ToolBarItemClick(e);
        }
        public override void AfterBarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterBarItemClickEventArgs e)
        {
            PrintEventInfo("AfterBarItemClick", e);
            base.AfterBarItemClick(e);
        }
        public override void AfterEntryBarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterBarItemClickEventArgs e)
        {
            PrintEventInfo("AfterEntryBarItemClick", e);
            base.AfterEntryBarItemClick(e);
        }
        public override void AfterToolBarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterBarItemClickEventArgs e)
        {
            PrintEventInfo("AfterToolBarItemClick", e);
            base.AfterToolBarItemClick(e);
        }
        public override void ButtonClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ButtonClickEventArgs e)
        {
            PrintEventInfo("ButtonClick", e);
            base.ButtonClick(e);
        }
        public override void ChangeHTmlTheme(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.HtmlThemeEventArgs e)
        {
            PrintEventInfo("ChangeHTmlTheme", e);
            base.ChangeHTmlTheme(e);
        }
        public override void EntryButtonCellClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntryButtonCellClickEventArgs e)
        {
            PrintEventInfo("EntryButtonCellClick", e);
            base.EntryButtonCellClick(e);
        }
        public override void AfterButtonClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterButtonClickEventArgs e)
        {
            PrintEventInfo("AfterButtonClick", e);
            base.AfterButtonClick(e);
        }
        public override void TreeNodeClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.TreeNodeArgs e)
        {
            PrintEventInfo("TreeNodeClick", e);
            base.TreeNodeClick(e);
        }
        public override void TreeNodeDoubleClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.TreeNodeArgs e)
        {
            PrintEventInfo("TreeNodeDoubleClick", e);
            base.TreeNodeDoubleClick(e);
        }
        public override void TreeLoadData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.TreeLoadDataArgs e)
        {
            PrintEventInfo("TreeLoadData", e);
            base.TreeLoadData(e);
        }
        public override void BeforeDoAction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeDoActionEventArgs e)
        {
            PrintEventInfo("BeforeDoAction", e);
            base.BeforeDoAction(e);
        }
        public override void AfterDoAction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterDoActionEventArgs e)
        {
            PrintEventInfo("AfterDoAction", e);
            base.AfterDoAction(e);
        }
        public override void AuthPermissionBeforeF7Select(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AuthPermissionBeforeF7SelectEventArgs e)
        {
            PrintEventInfo("AuthPermissionBeforeF7Select", e);
            base.AuthPermissionBeforeF7Select(e);
        }
        public override void BeforeF7Select(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeF7SelectEventArgs e)
        {
            PrintEventInfo("BeforeF7Select", e);
            base.BeforeF7Select(e);
        }
        public override void AfterF7Select(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterF7SelectEventArgs e)
        {
            PrintEventInfo("AfterF7Select", e);
            base.AfterF7Select(e);
        }
        public override void AfterQuickGetData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterQuickGetDataEventArgs e)
        {
            PrintEventInfo("AfterQuickGetData", e);
            base.AfterQuickGetData(e);
        }
        public override void AfterQuickSelect(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterQuickSelectEventArgs e)
        {
            PrintEventInfo("AfterQuickSelect", e);
            base.AfterQuickSelect(e);
        }
        public override void BeforeFlexSelect(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeFlexSelectEventArgs e)
        {
            PrintEventInfo("BeforeFlexSelect", e);
            base.BeforeFlexSelect(e);
        }
        public override void BeforeFilterGridF7Select(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeFilterGridF7SelectEventArgs e)
        {
            PrintEventInfo("BeforeFilterGridF7Select", e);
            base.BeforeFilterGridF7Select(e);
        }
        public override void AfterShowCustomerPage(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterShowCustomerPageEventArgs e)
        {
            PrintEventInfo("AfterShowCustomerPage", e);
            base.AfterShowCustomerPage(e);
        }
        public override void AfterShowForm(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterShowFormEventArgs e)
        {
            PrintEventInfo("AfterShowForm", e);
            base.AfterShowForm(e);
        }
        public override void BeforeDoOperation(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeDoOperationEventArgs e)
        {
            PrintEventInfo("BeforeDoOperation", e);
            base.BeforeDoOperation(e);
        }
        public override void BeforeOperAfterSelOrg(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeOperAfterSelOrgArgs e)
        {
            PrintEventInfo("BeforeOperAfterSelOrg", e);
            base.BeforeOperAfterSelOrg(e);
        }
        public override void AfterDoOperation(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterDoOperationEventArgs e)
        {
            PrintEventInfo("AfterDoOperation", e);
            base.AfterDoOperation(e);
        }
        public override void AfterConfirmOperation(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterConfirmOperationEventArgs e)
        {
            PrintEventInfo("AfterConfirmOperation", e);
            base.AfterConfirmOperation(e);
        }
        public override void ListViewClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ListViewClickArgs e)
        {
            PrintEventInfo("ListViewClick", e);
            base.ListViewClick(e);
        }
        public override void ListViewAddFavorClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ListViewClickArgs e)
        {
            PrintEventInfo("ListViewAddFavorClick", e);
            base.ListViewAddFavorClick(e);
        }
        public override void ListViewClearClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ListViewClickArgs e)
        {
            PrintEventInfo("ListViewClearClick", e);
            base.ListViewClearClick(e);
        }
        public override void TreeDragDrop(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.TreeDragDropEventArgs e)
        {
            PrintEventInfo("TreeDragDrop", e);
            base.TreeDragDrop(e);
        }
        public override void LanguageChanged(System.EventArgs e)
        {
            PrintEventInfo("LanguageChanged", e);
            base.LanguageChanged(e);
        }
        public override void EntityRowClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntityRowClickEventArgs e)
        {
            PrintEventInfo("EntityRowClick", e);
            base.EntityRowClick(e);
        }
        public override void EntryCellFocued(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntryCellFocuedEventArgs e)
        {
            PrintEventInfo("EntryCellFocued", e);
            base.EntryCellFocued(e);
        }
        public override void EntityRowDoubleClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntityRowClickEventArgs e)
        {
            PrintEventInfo("EntityRowDoubleClick", e);
            base.EntityRowDoubleClick(e);
        }
        public override void TabItemSelectedChange(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.TabItemSelectedChangeEventArgs e)
        {
            PrintEventInfo("TabItemSelectedChange", e);
            base.TabItemSelectedChange(e);
        }
        public override void CustomEvents(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.CustomEventsArgs e)
        {
            PrintEventInfo("CustomEvents", e);
            base.CustomEvents(e);
        }
        public override void RowExpanding(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntityRowClickEventArgs e)
        {
            PrintEventInfo("RowExpanding", e);
            base.RowExpanding(e);
        }
        public override void HeaderCellClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntityRowClickEventArgs e)
        {
            PrintEventInfo("HeaderCellClick", e);
            base.HeaderCellClick(e);
        }
        public override void DataUpdateBeginning()
        {
            PrintEventInfo("DataUpdateBeginning");
            base.DataUpdateBeginning();
        }
        public override void DataUpdateEnd()
        {
            PrintEventInfo("DataUpdateEnd");
            base.DataUpdateEnd();
        }
        public override void NaviOperAction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.NaviOperActionArgs e)
        {
            PrintEventInfo("NaviOperAction", e);
            base.NaviOperAction(e);
        }
        public override void FieldLabelClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.FieldLabelClickArgs e)
        {
            PrintEventInfo("FieldLabelClick", e);
            base.FieldLabelClick(e);
        }
        public override void FireEntityBlockPasting(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntityBlockPastingEventArgs e)
        {
            PrintEventInfo("FireEntityBlockPasting", e);
            base.FireEntityBlockPasting(e);
        }
        public override void BeforeF1Click(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.F1ClickArgs e)
        {
            PrintEventInfo("BeforeF1Click", e);
            base.BeforeF1Click(e);
        }
        public override void BeforeImportData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeImportDataArgs e)
        {
            PrintEventInfo("BeforeImportData", e);
            base.BeforeImportData(e);
        }
        public override void ImportDataCollectFailInfo(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ImportDataBeforeCollectFailInfoArgs e)
        {
            PrintEventInfo("ImportDataCollectFailInfo", e);
            base.ImportDataCollectFailInfo(e);
        }
        public override void BeforeExportData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeExportDataArgs e)
        {
            PrintEventInfo("BeforeExportData", e);
            base.BeforeExportData(e);
        }
        public override void BeforeEntityExport(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeEntityExportArgs e)
        {
            PrintEventInfo("BeforeEntityExport", e);
            base.BeforeEntityExport(e);
        }
        public override void FireEntryCheck(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.FEntryCheckArgs e)
        {
            PrintEventInfo("FireEntryCheck", e);
            base.FireEntryCheck(e);
        }
        public override void FireMicroBlogClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.FMicroBlogClickArgs e)
        {
            PrintEventInfo("FireMicroBlogClick", e);
            base.FireMicroBlogClick(e);
        }
        public override void PortDataReceived(Kingdee.BOS.DataEntity.KDSerialPortEventArgs e)
        {
            PrintEventInfo("PortDataReceived", e);
            base.PortDataReceived(e);
        }
        public override void MsgInnerControlEvent(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.MsgInnerControlEventArgs e)
        {
            PrintEventInfo("MsgInnerControlEvent", e);
            base.MsgInnerControlEvent(e);
        }
        public override void GetFormTitle(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.GetFormTitleEventArgs e)
        {
            PrintEventInfo("GetFormTitle", e);
            base.GetFormTitle(e);
        }
        public override void OnEntrySum(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EntrySumEventArgs e)
        {
            PrintEventInfo("OnEntrySum", e);
            base.OnEntrySum(e);
        }
        public override void OnQueryFlexFieldState(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.OnQueryFlexFieldStateEventArgs e)
        {
            PrintEventInfo("OnQueryFlexFieldState", e);
            base.OnQueryFlexFieldState(e);
        }
        public override void OnPrepareDevPrintData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePrintDevDataEventArgs e)
        {
            PrintEventInfo("OnPrepareDevPrintData", e);
            base.OnPrepareDevPrintData(e);
        }
        public override void OnPrepareNotePrintData(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePrintDataEventArgs e)
        {
            PrintEventInfo("OnPrepareNotePrintData", e);
            base.OnPrepareNotePrintData(e);
        }
        public override void OnPrepareNotePrintQueryParam(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PrepareNotePrintQueryParamEventArgs e)
        {
            PrintEventInfo("OnPrepareNotePrintQueryParam", e);
            base.OnPrepareNotePrintQueryParam(e);
        }
        public override void OnQueryDynamicColumns(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.QueryDynamicColumnsEventArgs e)
        {
            PrintEventInfo("OnQueryDynamicColumns", e);
            base.OnQueryDynamicColumns(e);
        }
        public override void OnAfterPrint(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterPrintEventArgs e)
        {
            PrintEventInfo("OnAfterPrint", e);
            base.OnAfterPrint(e);
        }
        public override System.Collections.Generic.List<Kingdee.BOS.Core.Metadata.EnumItem> GetValidNoteTemplates(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ValidNoteTemplatesEventArgs e)
        {
            PrintEventInfo("GetValidNoteTemplates", e);
            return base.GetValidNoteTemplates(e);
        }
        public override void OnAfterWebApiOperation(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterWebApiOperationArgs e)
        {
            PrintEventInfo("OnAfterWebApiOperation", e);
            base.OnAfterWebApiOperation(e);
        }
        public override void OnBeforeWebApiOperation(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterWebApiOperationArgs e)
        {
            PrintEventInfo("OnBeforeWebApiOperation", e);
            base.OnBeforeWebApiOperation(e);
        }
        #endregion
        #region private method
        /// <summary>
        /// 事件执行次数计数器
        /// </summary>
        private int counter;
        /// <summary>
        /// 事件执行次数计数器
        /// </summary>
        private int Counter
        {
            get { return ++counter; }
        }
        /// <summary>
        /// 输出事件执行日志
        /// </summary>
        /// <param name="eventName">事件名称</param>
        /// <param name="args">事件参数</param>
        private void PrintEventInfo(string eventName, params object[] args)
        {
            var formId = GetFormId();
            var parameters = string.Empty;
            try
            {
                //parameters = Newtonsoft.Json.JsonConvert.SerializeObject(args);// 性能较差，可能会导致页面假死
            }
            catch
            {
            }
            var log = string.Format("序号:{0},执行时间:{1},表单Id:{2},事件名称:{3},事件参数:{4}", Counter, DateTime.Now.ToString("yyyy -MM-dd HH:mm:ss.fff"), formId, eventName, parameters);
            System.Diagnostics.Debug.Print(log);
            Kingdee.BOS.Log.Logger.Error("EVENT", log, null);
        }
        /// <summary>
        /// 获取业务对象标识
        /// </summary>
        /// <returns></returns>
        private string GetFormId()
        {
            var formId = string.Empty;
            if (this.View != null && this.View.BillBusinessInfo != null)
            {
                formId = this.View.BillBusinessInfo.GetForm().Id;
            }
            return formId;
        }
        #endregion
    }
}
